//https://zhuanlan.zhihu.com/p/157812060
#include <setjmp.h>
#include <stdio.h>

jmp_buf jb;

int  sj_test() {
    int ret = 0;
    if((ret = setjmp(jb))) {
        printf("catch longjmp: %d\n", ret);    
    } else {
        printf("calling setjmp\n");
    }
    return ret;
}

void lj_test() {
    longjmp(jb, -1);
}

int main(void) {
    int ret = 0;
    if((ret = sj_test())) {
        return ret;
    }else {
        lj_test();
    }
    return 0;
}
